package com.tg.app.activity.device.add;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.CheckBox;

import androidx.annotation.Nullable;

import com.appbase.custom.config.ApiUrl;
import com.tg.app.R;
import com.base.BaseActivity;
import com.tg.app.activity.device.DeviceSettingsActivity;
import com.tg.app.helper.TGGlobalConfigHelper;
import com.tange.base.toolkit.StringUtils;
import com.tg.data.bean.DeviceSettingsInfo;
import com.tg.app.helper.ActivityHelper;
import com.tg.app.util.UriUtil;

import static com.tg.app.activity.device.DeviceSettingsActivity.EXT_DEVICE_INFO;

public class ResetDeviceActivity extends BaseActivity {
    private Button mButton;
    private String mUUID;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);//remove title bar  即隐藏标题栏
        setContentView(R.layout.activity_reset_device);
        if (getIntent() != null){
            mUUID = getIntent().getStringExtra(ApSetWifiActivityEx.EXT_WIFI_UUID);
        }
        hideActionBar();
        initView();
    }
    @Override
    public boolean shouldSetStatusBarColor() {
        return true;
    }
    protected void initView() {
        mButton = findViewById(R.id.next);
        ActivityHelper.setLoginStyleButtonEnable(mButton, false);
        mButton.setOnClickListener(v -> ActivityHelper.goToBindActivity(ResetDeviceActivity.this, mUUID, "reset"));
        View appIconView = findViewById(R.id.app_icon3);
        if (appIconView != null) {
            appIconView.setOnClickListener(v -> {
                Intent intent = new Intent();
                DeviceSettingsInfo info = getIntent().getParcelableExtra(EXT_DEVICE_INFO);
                intent.putExtra(DeviceSettingsActivity.EXT_DEVICE_INFO, info);
                String url = TGGlobalConfigHelper.getInstance().getHowToResetDevice();
                if (StringUtils.isEmpty(url)){
                    url = ApiUrl.APP_HELP_RESET;
                }
                UriUtil.openServePlayImpl(ResetDeviceActivity.this, intent, url, "", 0);
            });
        }


        CheckBox checkBox = findViewById(R.id.cb_message_filter_device_all);
        checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> ActivityHelper.setLoginStyleButtonEnable(mButton, isChecked));
        modifyToolBar(null, false);
        findViewById(R.id.back_toolbar).setOnClickListener(v -> finish());
    }
}
